package com.wbc.smartHome.service;

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wbc.smartHome.dao.NewsDao;
import com.wbc.smartHome.model.HotSpot;
import com.wbc.smartHome.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class HotSpotService {

    @Value("${aliyun.oss.endpoint}")
    private String endpoint;
    @Value("${aliyun.oss.accessKeyId}")
    private String accessKeyId;
    @Value("${aliyun.oss.accessKeySecret}")
    private String accessKeySecret;
    @Value("${aliyun.oss.bucketName}")
    private String bucketName;


    @Autowired
    private RedisTemplate redisTemplate;

    private String key = "hotspot";

    public List<HotSpot> getHotSpotList() {
        ListOperations listOps  = redisTemplate.opsForList();
        List<HotSpot> hotSpotList = listOps.range(key, 0, -1);
        return hotSpotList;
    }


    public void setHotSpot(HotSpot hotSpot) {
      ListOperations listOps  = redisTemplate.opsForList();
        listOps.rightPush(key, hotSpot);
    }
}
